package com.mt.grand.template.dao;

import com.mt.grand.template.JdbcTemplate;
import com.mt.grand.template.RowMapper;
import com.mt.grand.template.entity.Member;

import java.sql.ResultSet;
import java.util.List;

public class MemberDao {

    private JdbcTemplate jdbcTemplate = new JdbcTemplate(null);

    public List<?> query(){
        String sql = "select * from t_member";
        return jdbcTemplate.executeQuery(sql, new RowMapper<Object>() {
            @Override
            public Object mapRow(ResultSet rs, int rowNum) throws Exception {
                Member member = new Member();
                member.setUsername(rs.getString("username"));
                member.setPassword(rs.getString("password"));
                member.setNickName(rs.getString("nickName"));
                return member;
            }
        },null);
    }
}